<template>
  <div class="side-panel" :class="{ 'collapsed': isCollapsed }">
    <div class="panel-content" v-show="!isCollapsed">
      <div class="panel-header">
        <span>{{ title }}</span>
        <el-button
          class="collapse-button"
          type="primary"
          text
          @click="togglePanel"
        >
          <el-icon><ArrowUp /></el-icon>
          收起
        </el-button>
      </div>
      <slot></slot>
    </div>
    <div class="collapsed-content" v-show="isCollapsed">
      <div class="collapsed-text">{{ title }}</div>
      <el-button
        class="expand-button"
        type="primary"
        text
        @click="togglePanel"
      >
        <el-icon><ArrowDown /></el-icon>
        展开
      </el-button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ArrowUp, ArrowDown } from '@element-plus/icons-vue'

const props = defineProps({
  title: {
    type: String,
    required: true
  }
})

const isCollapsed = ref(false)
const emit = defineEmits(['update:collapsed'])

const togglePanel = () => {
  isCollapsed.value = !isCollapsed.value
  emit('update:collapsed', isCollapsed.value)
}
</script>

<style scoped>
.side-panel {
  position: relative;
  background-color: #fff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.panel-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity 0.3s;
}

.collapsed .panel-content {
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 500;
  color: #303133;
  border-bottom: 1px solid #e6e6e6;
  background-color: #f8f9fa;
}

.collapsed-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 16px;
  background: linear-gradient(to bottom, #f8f9fa, #ffffff);
  gap: 12px;
}

.collapsed-text {
  writing-mode: vertical-lr;
  text-orientation: upright;
  letter-spacing: 4px;
  color: #409EFF;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.collapse-button {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.3s;
}

.expand-button {
  writing-mode: vertical-lr;
  text-orientation: upright;
  padding: 12px 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #409EFF;
  border-radius: 4px;
  transition: all 0.3s;
}
</style> 